## Replication code for "Misinformation and the Justification of Socially Undesirable Preferences"
## D.J. Flynn and Yanna Krupnikov
## Journal of Experimental Political Science

## Note: This file contains code necessary to replicate results presented in the main text and some of the appendix results. 
## Additional replication code (in Stata format) can be found in the .do files included in this replication archive (we note 
## below where each result is replicated). For an explanation of all files included in the replication folder, 
## see "FlynnKrupnikov_README.docx" or contact the corresponding author at <d.j.flynn@dartmouth.edu>.

##################
### Load data: ###
##################

setwd("~/Dropbox/DJ_Yanna/SSI Data/")
library(foreign)
library(readstata13)
data<-read.dta13("FlynnKrupnikov.dta")
names(data)

##################
### Recoding: ####
##################
library(car)

## Treatment indicators ##

#Type of candidate factor:
#keep original codes of "cand_treat":
#1=same party, black
#2=same party, white
#3=other party, black
#4=other party, white

#Correction factor:
table(data$corr_treat) #original codes
#recode as numeric:
data$correction<-recode(data$corr_treat,"'No Correction'=1; 'Unattributed Correction'=2; 'Attributed Correction'=3",as.factor.result=FALSE)
table(data$correction) #new codes: 1=no correction; 2=unattributed correction; 3=attributed ("PolitiCheck") correction
#create indicator for either correction:
data$got.treatment<-ifelse(data$correction==2 | data$correction==3, 1, 0)
table(data$got.treatment,data$correction)

## Outcome variables ##

data$favorable_dv<-data$favorable #1-7
data$govern_dv<-data$govern #1-7
data$president_dv<-data$president #1-7
data$leader_dv<-data$leader #1-7
data$vote_dv<-recode(data$vote,"1=5;2=4;3=3;4=2;5=1;else=NA",as.factor.result=FALSE) #1-5

## Covariates ##

#keep original codes of data$pid1: 1=Dem, 2=Rep, 3=Ind
#keep original codes of data$ind_lean: 1=lean Dem, 2=lean Rep, 3=pure ind.
data$strong.dem<-recode(data$pid_dem,"1=1;2=0;else=NA",as.factor.result=FALSE) #1=strong Dem, 0 otherwise
data$strong.rep<-recode(data$pid_rep,"1=1;2=0;else=NA",as.factor.result=FALSE) #1=strong Rep, 0 otherwise
data$white<-recode(data$race,"1=1;2:5=0;else=NA",as.factor.result=FALSE) #1 if yes, 0 otherwise
data$hispan<-recode(data$spanish,"1=1;2=0;else=NA",as.factor.result=FALSE) #1 if yes, 0 otherwise
data$female<-recode(data$gender,"2=1;1=0;else=NA",as.factor.result=FALSE) #1 if yes, 0 otherwise
data$educ<-recode(data$educ,"-99=NA") #1-6 ascending
data$income<-recode(data$income,"-99=NA") #1-9 ascending
data$ideo<-recode(data$ideo,"-99=NA") #1-7, lib to conserv
data$interested<-recode(data$interest,"1=3;2=2;3=1;else=NA",as.factor.result=FALSE) #now 1-3 ascending

#Racial attitudes questions:
data$white.lazy<-recode(data$whitelazy,"-99=NA",as.factor.result=FALSE) #1-7 ascending hardworking
data$black.lazy<-recode(data$blacklazy,"-99=NA",as.factor.result=FALSE) #1-7 ascending hardworking
data$white.int<-recode(data$whiteint,"-99=NA",as.factor.result=FALSE) #1-7 ascending intelligent
data$black.int<-recode(data$blackint,"-99=NA",as.factor.result=FALSE) #1-7 ascending intelligent

###############################
### Creating Prejudice Score ##
###############################

##Create prejudice score per Piston 2010 Pol. Behav.
#diff on lazy question
data$lazy.diff.temp <- data$white.lazy - data$black.lazy
data$lazy.diff <- (data$lazy.diff.temp+6)/12 #re-scaled 0-1
#diff on intelligent question
data$unint.diff.temp <- data$white.int - data$black.int
data$unint.diff <- (data$unint.diff.temp+6)/12 #re-scaled 0-1
data$prej.temp <- data$lazy.diff.temp + data$unint.diff.temp
#final prej. score:
data$prej.scale <- (data$prej.temp + 12) / 24
summary(data$prej.scale)
hist(data$prej.scale,breaks=14)
abline(v=median(data$prej.scale,na.rm=T),lwd=4,col="red")
d<-density(data$prej.scale,na.rm=T)
plot(d)

#Creating subsets based on prejudice level: 
median(data$prej.scale, na.rm=T) #median is 0.5
above.prej.median <- subset(data, prej.scale>0.5) 
dim(above.prej.median) #n=333
below.prej.median <- subset(data, prej.scale<=0.5) 
dim(below.prej.median) #n=683

#Creating dummy indicator for above median prejudice level (1) or not (0):
data$above<-ifelse(data$prej.scale>(median(data$prej.scale,na.rm=T)),1,0)
table(data$above) #n_low prej=683. n_high prej=333.

###################################################
### Analyses for Table 2 (favorability ratings) ###
###################################################
#See "FlynnKrupnikov_Appendix Tables.do" for code to reproduce diff-in-diff analyses presented in this table

## Low prejudice participants (left side of Table 2):

#Same party, black candidate:
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==1],
       below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==2 | 
                                        below.prej.median$cand_treat==1 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.005
#Same party, white candidate:
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==1],
       below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==2 |
                                        below.prej.median$cand_treat==2 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.004

## High prejudice participants (right side of Table 2):

#Same party, black candidate:
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==1],
       above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==1 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.68

#Same party, white candidate:
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==1],
       above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==2 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.001

################
### Figure 1 ###
################

## Create new treatment dummy (0=no correction; 1=received attributed OR unattributed correction):
below.prej.median$correction.merged<-recode(below.prej.median$correction,"1=0;2:3=1",as.factor.result=F)
table(below.prej.median$correction.merged)
above.prej.median$correction.merged<-recode(above.prej.median$correction,"1=0;2:3=1",as.factor.result=F)
table(above.prej.median$correction.merged)

## Create two sub-plots for favorability ratings among low (left side) and high (right side) prejudice participants:
par(mfrow=c(1,2)) #sub-plots in 1 row, 2 columns
# Low Prejudice:
means_uncorrected <- c(mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==1],na.rm=T),
                       mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==2],na.rm=T),
                       mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==3],na.rm=T),
                       mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==4],na.rm=T))
means_uncorrected

means_corrected <- c(mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==1],na.rm=T),
                     mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==2],na.rm=T),
                     mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==3],na.rm=T),
                     mean(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==4],na.rm=T))
means_corrected

means<-rbind(means_uncorrected,means_corrected)
means

SE_uncorrected <- c(sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==1],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==1])),
                    sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==2],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==2])),
                    sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==3],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==3])),
                    sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==4],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==0 & below.prej.median$cand_treat==4])))

SE_uncorrected

SE_corrected <-c(sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==1],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==1])),
                 sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==2],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==2])),
                 sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==3],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==3])),
                 sd(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==4],na.rm=T)/sqrt(length(below.prej.median$favorable_dv[below.prej.median$correction.merged==1 & below.prej.median$cand_treat==4])))
SE_corrected

SE<-rbind(SE_uncorrected,SE_corrected)
SE

mp <- barplot(means, axes=FALSE, axisnames=FALSE, ylim=c(1, 6),   
              main="Low Prejudice Participants", xlab="Candidate Type", 
              ylab="Favorability (1-7)",xpd = FALSE, beside=TRUE,col=c("gray35","gray75"))
legend("topright", bty="n",c("No Correction","Correction"),fill=c("gray35","gray75"),cex=.75)

segments(mp, means - 1.96*SE, mp, means + 1.96*SE, lwd=2) #vert bar
axis(2, at=seq(1, 6, by=1),labels=NULL)
mtext("Same Party,\nBlack", side=1, line=1, at=2)
mtext("Same Party,\nWhite", side=1, line=1, at=5)
mtext("Other Party,\nBlack", side=1, line=1, at=8)
mtext("Other Party,\nWhite", side=1, line=1, at=11)
box()

# High prejudice:
means_uncorrected <- c(mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==1],na.rm=T),
                       mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==2],na.rm=T),
                       mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==3],na.rm=T),
                       mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==4],na.rm=T))
means_uncorrected

means_corrected <- c(mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==1],na.rm=T),
                     mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==2],na.rm=T),
                     mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==3],na.rm=T),
                     mean(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==4],na.rm=T))
means_corrected

means<-rbind(means_uncorrected,means_corrected)
means

SE_uncorrected <- c(sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==1],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==1])),
                    sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==2],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==2])),
                    sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==3],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==3])),
                    sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==4],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==0 & above.prej.median$cand_treat==4])))

SE_uncorrected

SE_corrected <-c(sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==1],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==1])),
                 sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==2],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==2])),
                 sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==3],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==3])),
                 sd(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==4],na.rm=T)/sqrt(length(above.prej.median$favorable_dv[above.prej.median$correction.merged==1 & above.prej.median$cand_treat==4])))
SE_corrected

SE<-rbind(SE_uncorrected,SE_corrected)
SE

mp <- barplot(means, axes=FALSE, axisnames=FALSE, ylim=c(1, 6),   
              main="High Prejudice Participants", xlab="Candidate Type", 
              ylab="Favorability (1-7)",xpd = FALSE, beside=TRUE,col=c("gray35","gray75"))
legend("topright", bty="n",c("No Correction","Correction"),fill=c("gray35","gray75"),cex=.75)

segments(mp, means - 1.96*SE, mp, means + 1.96*SE, lwd=2) #vert bar
axis(2, at=seq(1, 6, by=1),labels=NULL)
mtext("Same Party,\nBlack", side=1, line=1, at=2)
mtext("Same Party,\nWhite", side=1, line=1, at=5)
mtext("Other Party,\nBlack", side=1, line=1, at=8)
mtext("Other Party,\nWhite", side=1, line=1, at=11)
box()

#######################
### Appendix Results ##
#######################

# Appendix 1 "Table with Additional Details" : sample N at various stages of the CONSORT participant flow was taken from the raw data. See Appendix Table 3C for more information on N by condition and effect size.

# Appendix Table 2A1: Sample Demographics:

table(data$pid1) #1=Dem, 2=Rep, 3=Ind
pct.dem <- 387/length(data$pid1)
pct.dem

pct.rep <- 256/length(data$pid1)
pct.rep

table(data$educ) #5/6=BA or higher
pct.BA <- (273+153)/length(data$educ)
pct.BA

table(data$female)
pct.male <- 452/length(data$female)
pct.male

table(data$income)
median(data$income, na.rm=T) #$40-50k

# Appendix Table 3A1 (Multinomial Logit): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 3A2 (Racial Prejudice Scale): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 3A3 (Race): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 3B1 (Predicting Missing Values in Post-Treatment Data): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 3C1 (Comparisons of Cell Size and Effect): see "FlynnKrupnikov_Table 3C1.xlsx"

# Appendix Table 4A1 (Mean Favorability Ratings by Experimental Conditions, with Breakdowns by Prejudice Level):

##All participants (left panel):
#same party black candidates:
mean(data$favorable_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
sd(data$favorable_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
mean(data$favorable_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
sd(data$favorable_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
#same party white candidates:
mean(data$favorable_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
sd(data$favorable_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
mean(data$favorable_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
sd(data$favorable_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
#other party black candidates:
mean(data$favorable_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
sd(data$favorable_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
mean(data$favorable_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
sd(data$favorable_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
#other party white candidates:
mean(data$favorable_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
sd(data$favorable_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
mean(data$favorable_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)
sd(data$favorable_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)

#Low Prejudice (center panel):
#same party black candidates:
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)

#High Prejudice (right panel:)
#same party black candidates:
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)


# Appendix Table 4A2 (Mean Likelihood of Voting for Candidate by Experimental Conditions, with Breakdowns by Prejudice Level):

##All participants (left panel):
#same party black candidates:
mean(data$vote_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
sd(data$vote_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
mean(data$vote_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
sd(data$vote_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
#same party white candidates:
mean(data$vote_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
sd(data$vote_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
mean(data$vote_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
sd(data$vote_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
#other party black candidates:
mean(data$vote_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
sd(data$vote_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
mean(data$vote_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
sd(data$vote_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
#other party white candidates:
mean(data$vote_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
sd(data$vote_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
mean(data$vote_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)
sd(data$vote_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)

#Low Prejudice (center panel):
#same party black candidates:
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)

#High Prejudice (right panel:)
#same party black candidates:
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)


# Appendix Table 4A3 (Mean Effective Governor Ratings by Experimental Conditions, with Breakdowns by Prejudice Level):

##All participants (left panel):
#same party black candidates:
mean(data$govern_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
sd(data$govern_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
mean(data$govern_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
sd(data$govern_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
#same party white candidates:
mean(data$govern_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
sd(data$govern_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
mean(data$govern_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
sd(data$govern_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
#other party black candidates:
mean(data$govern_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
sd(data$govern_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
mean(data$govern_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
sd(data$govern_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
#other party white candidates:
mean(data$govern_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
sd(data$govern_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
mean(data$govern_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)
sd(data$govern_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)

#Low Prejudice (center panel):
#same party black candidates:
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)

#High Prejudice (right panel:)
#same party black candidates:
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)


# Appendix Table 4A4 (Mean Effective President Ratings by Experimental Conditions, with Breakdowns by Prejudice Level):

##All participants (left panel):
#same party black candidates:
mean(data$president_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
sd(data$president_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
mean(data$president_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
sd(data$president_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
#same party white candidates:
mean(data$president_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
sd(data$president_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
mean(data$president_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
sd(data$president_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
#other party black candidates:
mean(data$president_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
sd(data$president_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
mean(data$president_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
sd(data$president_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
#other party white candidates:
mean(data$president_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
sd(data$president_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
mean(data$president_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)
sd(data$president_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)

#Low Prejudice (center panel):
#same party black candidates:
mean(below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)

#High Prejudice (right panel:)
#same party black candidates:
mean(above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)

# Appendix Table 4A5 (Mean Leadership Ratings by Experimental Conditions, with Breakdowns by Prejudice Level): see "FlynnKrupnikov_Appendix Tables.do"

##All participants (left panel):
#same party black candidates:
mean(data$leader_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
sd(data$leader_dv[data$cand_treat==1 & data$got.treatment==0], na.rm=T)
mean(data$leader_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
sd(data$leader_dv[data$cand_treat==1 & data$got.treatment==1], na.rm=T)
#same party white candidates:
mean(data$leader_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
sd(data$leader_dv[data$cand_treat==2 & data$got.treatment==0], na.rm=T)
mean(data$leader_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
sd(data$leader_dv[data$cand_treat==2 & data$got.treatment==1], na.rm=T)
#other party black candidates:
mean(data$leader_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
sd(data$leader_dv[data$cand_treat==3 & data$got.treatment==0], na.rm=T)
mean(data$leader_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
sd(data$leader_dv[data$cand_treat==3 & data$got.treatment==1], na.rm=T)
#other party white candidates:
mean(data$leader_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
sd(data$leader_dv[data$cand_treat==4 & data$got.treatment==0], na.rm=T)
mean(data$leader_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)
sd(data$leader_dv[data$cand_treat==4 & data$got.treatment==1], na.rm=T)

#Low Prejudice (center panel):
#same party black candidates:
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==1 & below.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==2 & below.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==3 & below.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==0], na.rm=T)
mean(below.prej.median$leader_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)
sd(below.prej.median$leader_dv[below.prej.median$cand_treat==4 & below.prej.median$got.treatment==1], na.rm=T)

#High Prejudice (right panel:)
#same party black candidates:
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==1 & above.prej.median$got.treatment==1], na.rm=T)
#same party white candidates:
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==2 & above.prej.median$got.treatment==1], na.rm=T)
#other party black candidates:
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==3 & above.prej.median$got.treatment==1], na.rm=T)
#other party white candidates:
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==0], na.rm=T)
mean(above.prej.median$leader_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)
sd(above.prej.median$leader_dv[above.prej.median$cand_treat==4 & above.prej.median$got.treatment==1], na.rm=T)

# Appendix Table 4B1 (Mean Favorability Ratings by Experimental Condition, with Breakdowns by Prejudice Level and D-I-D Comparisons): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4B2 (Mean Likelihoood of Voting for Candidate by Experimental Condition, with Breakdowns by Prejudice Level and D-I-D Comparisons): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4B3 (Mean Effective Governor Ratings by Experimental Condition, with Breakdowns by Prejudice Level and D-I-D Comparisons): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4B4 (Mean Effective President Ratings by Experimental Condition, with Breakdowns by Prejudice Level and D-I-D Comparisons): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4B5 (Mean Leadership Ratings by Experimental Condition, with Breakdowns by Prejudice Level and D-I-D Comparisons): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4C1 (Comparisons within Correction Condition): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4D1 (Weak Partisans, High Prejudice): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4E1 (Robustness Check: Effect of Attributed Correction on Candidate Evaluations, by Type of Candidate and Prejudice Level):  see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4E2 (Robustness Check: Effect of Unattributed Correction on Candidate Evaluations, by Type of Candidate and Prejudice Level): see "FlynnKrupnikov_Appendix Tables.do"

# Appendix Table 4F1 (Triple Interaction Models (Low Prejudice Participants)):

#create separate race/party/correction variables in low prejudice Rs subset:
below.prej.median$cand_black<-recode(below.prej.median$cand_treat,"1=1;2=0;3=1;4=0;else=NA",as.factor.result=F)
table(below.prej.median$cand_black, below.prej.median$cand_treat) #check coding
below.prej.median$cand_sameparty<-recode(below.prej.median$cand_treat,"1=1;2=1;3=0;4=0;else=NA",as.factor.result=F)
table(below.prej.median$cand_sameparty, below.prej.median$cand_treat) #check coding
below.prej.median$got.treatment<-ifelse(below.prej.median$correction==2 | below.prej.median$correction==3, 1, 0)
table(below.prej.median$correction,below.prej.median$got.treatment)

triple.low1<-lm(favorable_dv~cand_black*cand_sameparty*got.treatment,data=below.prej.median)
summary(triple.low1) #column 2
triple.low2<-lm(vote_dv~cand_black*cand_sameparty*got.treatment,data=below.prej.median)
summary(triple.low2) #column 3
triple.low3<-lm(govern_dv~cand_black*cand_sameparty*got.treatment,data=below.prej.median)
summary(triple.low3) #column 4
triple.low4<-lm(president_dv~cand_black*cand_sameparty*got.treatment,data=below.prej.median)
summary(triple.low4) #column 5

# Appendix Table 4F2 (Triple Interaction Models (High Prejudice Participants)):

#create separate race/party/correction variables in high prejudice Rs subset:
above.prej.median$cand_black<-recode(above.prej.median$cand_treat,"1=1;2=0;3=1;4=0;else=NA",as.factor.result=F)
table(above.prej.median$cand_black, above.prej.median$cand_treat) #check coding
above.prej.median$cand_sameparty<-recode(above.prej.median$cand_treat,"1=1;2=1;3=0;4=0;else=NA",as.factor.result=F)
table(above.prej.median$cand_sameparty, above.prej.median$cand_treat) #check coding
above.prej.median$got.treatment<-ifelse(above.prej.median$correction==2 | above.prej.median$correction==3, 1, 0)
table(above.prej.median$correction,above.prej.median$got.treatment)

triple.high1<-lm(favorable_dv~cand_black*cand_sameparty*got.treatment,data=above.prej.median)
summary(triple.high1) #column 2
triple.high2<-lm(vote_dv~cand_black*cand_sameparty*got.treatment,data=above.prej.median)
summary(triple.high2) #column 3
triple.high3<-lm(govern_dv~cand_black*cand_sameparty*got.treatment,data=above.prej.median)
summary(triple.high3) #column 4
triple.high4<-lm(president_dv~cand_black*cand_sameparty*got.treatment,data=above.prej.median)
summary(triple.high4) #column 5

# Appendix Table 5A1 (Logit Models Predicting High Prejudice Classification):

prej.reg1<-glm(above~got.treatment,data=data,subset=(data$cand_treat==1),family=binomial(link=logit))
summary(prej.reg1) #n.s.
prej.reg2<- glm(above~got.treatment,data=data,subset=(data$cand_treat==2),family=binomial(link=logit))
summary(prej.reg2) #n.s.
prej.reg3<- glm(above~got.treatment,data=data,subset=(data$cand_treat==3),family=binomial(link=logit))
summary(prej.reg3) #n.s.
prej.reg4<- glm(above~got.treatment,data=data,subset=(data$cand_treat==4),family=binomial(link=logit))
summary(prej.reg4) #n.s.

# Appendix Table 5A2 (Logit Models Predicting High Prejudice Classification (with Education)):

#logit models with treatment dummies, education, and treatment*education as predictors:
#education measured 1-6. dichotomizing at median, which is 4:
data$high.edu1<-ifelse(data$edu>median(data$edu, na.rm=T), 1, 0)
table(data$high.edu1) #n_high edu=426. n_low edu=601.

prej.reg5<-glm(above~got.treatment*high.edu1,data=data,subset=(data$cand_treat==1),family=binomial(link=logit))
summary(prej.reg5) #n.s.
prej.reg6<- glm(above~got.treatment*high.edu1,data=data,subset=(data$cand_treat==2),family=binomial(link=logit))
summary(prej.reg6) #n.s.
prej.reg7<- glm(above~got.treatment*high.edu1,data=data,subset=(data$cand_treat==3),family=binomial(link=logit))
summary(prej.reg7) #coeff on high education is p=.09
prej.reg8<- glm(above~got.treatment*high.edu1,data=data,subset=(data$cand_treat==4),family=binomial(link=logit))
summary(prej.reg8) #n.s.

#####################################
### Re-contact study (Appendix 5) ###
#####################################

### NOTE: before analyzing the re-contact data, we create a merged dataset including everyone's t1 responses 
# and the t2 responses from participants who participated in the re-contact study.

setwd("~/Dropbox/DJ_Yanna/SSI recontact Winter 2016/") #insert your wd

## Data from original study (t1): 
data<-read.dta("original dataset with panel id good.dta")
dim(data) #n=2020 in total. n=1031 our study; see "FlynnKrupnikov_dataset construction.docx" for details
names(data)
#write out same data as .csv:
#write.table(data,"original dataset with panel id good.csv",sep=",")

library(car)
#make t1 prejudice indicator:
data$white.lazy<-recode(data$whitelazy,"-99=NA") #1-7 ascending hardworking
data$black.lazy<-recode(data$blacklazy,"-99=NA") #1-7 ascending hardworking
data$white.int<-recode(data$whiteint,"-99=NA") #1-7 ascending intelligent
data$black.int<-recode(data$blackint,"-99=NA") #1-7 ascending intelligent
##create prejudice score per Piston 2010 Pol. Behav.)
#diff on lazy question
data$lazy.diff.temp <- data$white.lazy - data$black.lazy
data$lazy.diff <- (data$lazy.diff.temp+6)/12 #re-scaled 0-1
#diff on unintelligent question
data$unint.diff.temp <- data$white.int - data$black.int
data$unint.diff <- (data$unint.diff.temp+6)/12 #re-scaled 0-1
data$prej.temp <- data$lazy.diff.temp + data$unint.diff.temp
#final prej. score:
data$prej.scale <- (data$prej.temp + 12) / 24
summary(data$prej.scale)
data$high.prej_t1 <- ifelse(data$prej.scale>median(data$prej.scale,na.rm=T), 1, 0) 
table(data$high.prej_t1) #n=333
data$low.prej_t1 <- ifelse(data$prej.scale<=median(data$prej.scale,na.rm=T), 1, 0) 
table(data$low.prej_t1) #n=683
above.prej.median <- subset(data, prej.scale>median(data$prej.scale,na.rm=T)) 
dim(above.prej.median) #n=333
below.prej.median <- subset(data, prej.scale<=median(data$prej.scale,na.rm=T)) 
dim(below.prej.median) #n=684

#covariates used below:
data$female<-recode(data$gender,"2=1;1=0;else=NA",as.factor.result = F) #1 if yes, 0 otherwise
data$educ<-recode(data$educ,"-99=NA",as.factor.result=F) #1-6 ascending
data$income.new<-recode(data$income,"-99=NA",as.factor.result=F) #1-9 ascending
data$pid1.new<-recode(data$pid1,"1=2;2=3;3=1;else=NA",as.factor.result = F) #new ordering: 1=ind, 2=Dem, 3=Rep

## Recontact data (t2):
data2<-read.dta("SSI recontact dataset old.dta")
dim(data2) #n=845
names(data2)

## Merging old data with recontact data: 
merged<-merge(data, data2, by="pid")
dim(merged) #n=312
names(merged) #notice variables that appeared in both have ".x" and ".y" (distributions the same)

## Recoding new variables (from re-contact study):

# Racial attitudes:
table(merged$white_lazy) #NAs are -99s
merged$white_lazy.new<-recode(merged$white_lazy, "-99=NA;1=1;2=2;3=3;4=4;5=5;6=6;7=7;else=NA",as.factor.result=F)
table(merged$white_lazy.new)
table(merged$black_lazy) #NAs are -99s
merged$black_lazy.new<-recode(merged$black_lazy, "-99=NA;1=1;2=2;3=3;4=4;5=5;6=6;7=7;else=NA",as.factor.result=F)
table(merged$black_lazy.new)
table(merged$white_int)
table(merged$black_int)
#Create prejudice score per Piston 2010 Pol. Behav.:
#diff on lazy question
merged$lazy.diff.temp <- merged$white_lazy.new - merged$black_lazy.new
merged$lazy.diff <- (merged$lazy.diff.temp+6)/12 #re-scaled 0-1
#diff on unintelligent question
merged$int.diff.temp <- merged$white_int - merged$black_int
merged$int.diff <- (merged$int.diff.temp+6)/12 #re-scaled 0-1
merged$prej.temp <- merged$lazy.diff.temp + merged$int.diff.temp
#final prej. score:
merged$prej.scale <- (merged$prej.temp + 12) / 24
summary(merged$prej.scale) #note coding: high prej=above median, low prej=at or below median
hist(merged$prej.scale,breaks=14)
abline(v=median(merged$prej.scale,na.rm=T),lwd=4,col="red")
d<-density(merged$prej.scale,na.rm=T)
plot(d)

# Treatments:
#original codes: data$cand_treat: 1=same party, black. 2=same party, white. 3=other party, black. 4=other party, white.
merged$correction<-recode(merged$corr_treat,"'No Correction'=1; 'Unattributed Correction'=2; 'Attributed Correction'=3",as.factor.result=FALSE)
table(merged$correction) #Note new codes: 1=no correction; 2=unattributed correction; 3=attributed ("PolitiCheck") correction.

# DVs:
merged$favorable_dv<-merged$favorable #1-7
merged$govern_dv<-merged$govern #1-7
merged$president_dv<-merged$president #1-7
merged$leader_dv<-merged$leader #1-7
merged$vote_dv<-recode(merged$vote,"1=5;2=4;3=3;4=2;5=1;else=NA") #1-5

## Begin re-contact analysis:

# Appendix Table 5B1 (Logit Models Predicting Participation in Re-contact Survey):

#create indicator for whether recontacted: 1 if original ID is in recontact data, 0 otherwise:
data$recontacted<-ifelse(is.element(data$pid, merged$pid)==TRUE,1,0)
#merge two correction conditions (as did in main analyses), such that 1=corrected, 0=uncorrected:
data$correction.new<-recode(data$corr_treat,"'No Correction'=0;'Attributed Correction'=1;'Unattributed Correction'=1;else=NA",as.factor.result=F)
table(data$correction.new)
table(data$correction.new, data$corr_treat) #verify coding
#create indicator for original exp. condition:
data$condition<-ifelse(data$cand_treat==1 & data$correction.new==0, 1,
                       ifelse(data$cand_treat==1 & data$correction.new==1, 2,
                              ifelse(data$cand_treat==2 & data$correction.new==0, 3,
                                     ifelse(data$cand_treat==2 & data$correction.new==1, 4,
                                            ifelse(data$cand_treat==3 & data$correction.new==0, 5,
                                                   ifelse(data$cand_treat==3 & data$correction.new==1, 6,
                                                          ifelse(data$cand_treat==4 & data$correction.new==0, 7,
                                                                 ifelse(data$cand_treat==4 & data$correction.new==1, 8, NA))))))))
#logit models (Table 5B1):
recontact.logit1<-glm(recontacted~as.factor(condition),family=binomial(link=logit),data=data)
summary(recontact.logit1) #column 2
recontact.logit2<-glm(recontacted~as.factor(condition)+female+educ+income.new+as.factor(pid1),family=binomial(link=logit),data=data)
summary(recontact.logit2) #column 3

# Appendix Table 5B2 (Logit Models Predicting High Prejudice Classification (with Self Monitoring)):

#models with treatment dummies, social monitoring (SM), and treatment*SM as predictors:
#SM scale from Berinsky and Levine (2011)
merged$sm1<-recode(merged$sm_1,"1=3;2=2;3=1;else=NA",as.factor.result = F)
merged$sm2<-recode(merged$sm_2,"-99=NA;5=1;4=2;3=3;2=4;1=5;else=NA",as.factor.result = F)
merged$sm3<-recode(merged$sm_3,"5=1;4=2;3=3;2=4;1=5;else=NA",as.factor.result = F)
merged$sm.score<-(merged$sm1+merged$sm2+merged$sm3)
median(merged$sm.score,na.rm=T) #median is 6
merged$high.sm<-ifelse(merged$sm.score>median(merged$sm.score,na.rm=T), 1, 0) 
table(merged$high.sm) #145 are high SM, 155 are low.

#Column 2:
sm.reg1<-glm(high.prej_t1~as.factor(correction)*high.sm,data=merged,family=binomial(link=logit))
summary(sm.reg1) #n.s.
#Column 3:
sm.reg2<-glm(high.prej_t1~as.factor(correction)*high.sm,data=merged,subset=(merged$cand_treat==1),family=binomial(link=logit))
summary(sm.reg2) #n.s.
#Column 4:
sm.reg3<- glm(high.prej_t1~as.factor(correction)*high.sm,data=merged,subset=(merged$cand_treat==2),family=binomial(link=logit))
summary(sm.reg3) #n.s.
#Column 5:
sm.reg4<- glm(high.prej_t1~as.factor(correction)*high.sm,data=merged,subset=(merged$cand_treat==3),family=binomial(link=logit))
summary(sm.reg4) #n.s.
#Column 6:
sm.reg5<- glm(high.prej_t1~as.factor(correction)*high.sm,data=merged,subset=(merged$cand_treat==4),family=binomial(link=logit))
summary(sm.reg5) #n.s.

# Appendix Table 5B3 (Correlation Between Prejudice at Time of Initial Contact and at Re-contact):

#t1 measured already recoded above; need to recode t2 measures to get rid of NAs:
merged$white_lazy_w2 <- recode(merged$white_lazy, "-99=NA",as.factor.result=F) #1-7 ascending hardworking
merged$black_lazy_w2 <- recode(merged$black_lazy, "-99=NA",as.factor.result=F) #1-7 ascending hardworking
merged$white_int_w2 <- recode(merged$white_int, "-99=NA",as.factor.result=F) #1-7 ascending intelligent
merged$black_int_w2 <- recode(merged$black_int, "-99=NA",as.factor.result=F) #1-7 ascending intelligent

# Correlations across waves:
cor.test(merged$white.lazy, merged$white_lazy_w2, use="complete") #cor=0.38 (p<.001)
# Blacks lazy:
cor.test(merged$black.lazy, merged$black_lazy_w2, use="complete") #cor=0.56 (p<.001)
# Whites unintelligent:
cor.test(merged$white.int, merged$white_int_w2, use="complete") #cor=0.46 (p<.001)
# Blacks unintelligent:
cor.test(merged$black.int, merged$black_int_w2, use="complete") #cor=0.50 (p<.001)

# Appendix Table 5B4 (Correlation Between Racial Prejudice Measures in ANES): results from Piston (2018)

# Appendix Table 5B5 (Effect of Correction on Candidate Evaluations, by Type of Candidate and Prejudice Level):
# (same analysis as Table 2 in main text, except using prejudice measures from re-contact study)

# Top half of Appendix Table 5B5 (high prejudice participants):

#create high/low prejudice subsets (same procedure as above:)
median(merged$prej.scale, na.rm=T) #median is 0.5
above.prej.median <- subset(merged, prej.scale>median(merged$prej.scale,na.rm=T)) 
dim(above.prej.median) #n=137
below.prej.median <- subset(merged, prej.scale<=median(merged$prej.scale,na.rm=T)) 
dim(below.prej.median) #n=161

##Favorability by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==1],
       above.prej.median$favorable_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==1 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.45

#Same Party, White
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==1], 
       above.prej.median$favorable_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==2 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==1],
       above.prej.median$favorable_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==3 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, White
#no correction vs. either correction: 
t.test(above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==1],
       above.prej.median$favorable_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==2 | 
                                        above.prej.median$cand_treat==4 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01


##Vote likelihood by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==1],
       above.prej.median$vote_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==2 |
                                   above.prej.median$cand_treat==1 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.84

#Same Party, White
#no correction vs. either correction: 
t.test(above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==1],
       above.prej.median$vote_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==2 |
                                   above.prej.median$cand_treat==2 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.31

#Other Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==1],
       above.prej.median$vote_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==2 |
                                   above.prej.median$cand_treat==3 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.29

#Other Party, White
#no correction vs. either correction: 
t.test(above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==1],
       above.prej.median$vote_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==2 |
                                   above.prej.median$cand_treat==4 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.08

##Gubernatorial success by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==1],
       above.prej.median$govern_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==2 |
                                     above.prej.median$cand_treat==1 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.61

#Same Party, White
#no correction vs. either correction: 
t.test(above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==1],
       above.prej.median$govern_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==2 |
                                     above.prej.median$cand_treat==2 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==1],
       above.prej.median$govern_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==2 |
                                     above.prej.median$cand_treat==3 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, White
#no correction vs. either correction: 
t.test(above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==1],
       above.prej.median$govern_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==2 |
                                     above.prej.median$cand_treat==4 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.08


##Presidential success by type of correction (broken down by party/race type)
#no correction vs. either correction: 
t.test(above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==1],
       above.prej.median$president_dv[above.prej.median$cand_treat==1 & above.prej.median$correction==2 |
                                        above.prej.median$cand_treat==1 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.58

#Same Party, White
#no correction vs. either correction: 
t.test(above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==1],
       above.prej.median$president_dv[above.prej.median$cand_treat==2 & above.prej.median$correction==2 |
                                        above.prej.median$cand_treat==2 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.02

#Other Party, Black
#no correction vs. either correction: 
t.test(above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==1],
       above.prej.median$president_dv[above.prej.median$cand_treat==3 & above.prej.median$correction==2 |
                                        above.prej.median$cand_treat==3 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.01

#Other Party, White
#no correction vs. either correction: 
t.test(above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==1],
       above.prej.median$president_dv[above.prej.median$cand_treat==4 & above.prej.median$correction==2 |
                                        above.prej.median$cand_treat==4 & above.prej.median$correction==3],na.rm=T,var.equal=F) #p=.08


# Bottom half of Appendix Table 5B5 (low prejudice participants):

##Favorability by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==1],
       below.prej.median$favorable_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==2 | 
                                        below.prej.median$cand_treat==1 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.12

#Same Party, White
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==1], 
       below.prej.median$favorable_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==2 | 
                                        below.prej.median$cand_treat==2 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==1],
       below.prej.median$favorable_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==2 | 
                                        below.prej.median$cand_treat==3 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, White
#no correction vs. either correction: 
t.test(below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==1],
       below.prej.median$favorable_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==2 | 
                                        below.prej.median$cand_treat==4 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01


##Vote likelihood by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==1],
       below.prej.median$vote_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==2 |
                                   below.prej.median$cand_treat==1 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.22

#Same Party, White
#no correction vs. either correction: 
t.test(below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==1],
       below.prej.median$vote_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==2 |
                                   below.prej.median$cand_treat==2 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.47

#Other Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==1],
       below.prej.median$vote_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==2 |
                                   below.prej.median$cand_treat==3 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.29

#Other Party, White
#no correction vs. either correction: 
t.test(below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==1],
       below.prej.median$vote_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==2 |
                                   below.prej.median$cand_treat==4 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.08

##Gubernatorial success by type of correction (broken down by party/race type)
#Same Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==1],
       below.prej.median$govern_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==2 |
                                     below.prej.median$cand_treat==1 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.42

#Same Party, White
#no correction vs. either correction: 
t.test(below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==1],
       below.prej.median$govern_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==2 |
                                     below.prej.median$cand_treat==2 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.20

#Other Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==1],
       below.prej.median$govern_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==2 |
                                     below.prej.median$cand_treat==3 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, White
#no correction vs. either correction: 
t.test(below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==1],
       below.prej.median$govern_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==2 |
                                     below.prej.median$cand_treat==4 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.17


##Presidential success by type of correction (broken down by party/race type)
#no correction vs. either correction: 
t.test(below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==1],
       below.prej.median$president_dv[below.prej.median$cand_treat==1 & below.prej.median$correction==2 |
                                        below.prej.median$cand_treat==1 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.30

#Same Party, White
#no correction vs. either correction: 
t.test(below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==1],
       below.prej.median$president_dv[below.prej.median$cand_treat==2 & below.prej.median$correction==2 |
                                        below.prej.median$cand_treat==2 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.05

#Other Party, Black
#no correction vs. either correction: 
t.test(below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==1],
       below.prej.median$president_dv[below.prej.median$cand_treat==3 & below.prej.median$correction==2 |
                                        below.prej.median$cand_treat==3 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p<.01

#Other Party, White
#no correction vs. either correction: 
t.test(below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==1],
       below.prej.median$president_dv[below.prej.median$cand_treat==4 & below.prej.median$correction==2 |
                                        below.prej.median$cand_treat==4 & below.prej.median$correction==3],na.rm=T,var.equal=F) #p=.08

# Appendix Table 7 (No Differences in Evaluations of Candidates with and without Flag Pins)): See "FlynnKrupnikov_SuitCheck.dta" and "FlynnKrupnikov_SuitCheck.do"

 